#ifndef __MYSQL_PROTOCOL_H__
#define __MYSQL_PROTOCOL_H__

#include "base_protocol.h"

namespace secsmart_protocol
{
    enum PHASE_TYPE { PHASE_FULL_LINK = 0, PHASE_HALF_LINK };
    class MySQLProtocol: public BaseProtocol{
    public:
        MySQLProtocol(){
            databaseName = DBNAME_MYSQL;
        }
        virtual DETECT_RESULT parse(secsmart_session::session_sptr session, const uint8_t *buf, size_t size, bool is_forward);
        std::string extendInfo();
    
    private:
        void parseVersion(const uint8_t *buf, size_t size);
        bool checkIfTheDataIsCompressed(const uint8_t *buf, size_t size);
        void isBinlogResponse(const uint8_t *buf, size_t size);
    
    private:
        std::string versionInfo = "";
        uint16_t phase_ = PHASE_TYPE::PHASE_HALF_LINK;
        bool gotLoginReq_ = false;
        size_t left_length_ = 0;
        uint32_t packet_number_ = 0;
        uint32_t binlogSize = 0;
    };
}

#endif